package com.hs.wa.service;


import com.hs.wa.utls.RedisCacheOfMysql;
import com.springnew.dao.RuleconfigMapper;
import com.springnew.model.Ruleconfig;
import com.springnew.model.RuleconfigExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Wcs
 */
@Service
public class RuleConfigService {
    @Autowired
    private RuleconfigMapper ruleconfigMapper;


    @Autowired
    private  RedisCacheOfMysql redisCacheOfMysql;

    public List<Ruleconfig> selectRuleConfig() {

        int a = 2;
        RuleconfigExample ruleconfigCondition = new RuleconfigExample();
        List<Ruleconfig> ruleconfigs;
        if (a == 1) {
            ruleconfigCondition.createCriteria().andStatusEqualTo("1");
            ruleconfigs = ruleconfigMapper.selectByExample(ruleconfigCondition);
        } else {
            ruleconfigs = redisCacheOfMysql.selectMysqlForJdbcNoMap(Ruleconfig.class, "status", "1");
        }
        return ruleconfigs;
    }


    public boolean insertRuleConfig(Ruleconfig ruleconfig) {

        Boolean flag = false;
        int i = ruleconfigMapper.insertSelective(ruleconfig);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }
}
